/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package csse3004.GD;

import csse3004.GD.DA.LoginDA;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.web.servlet.mvc.SimpleFormController;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.view.RedirectView;

/**
 *
 * @author David Bullock 42062222
 */
public class changePasswordController extends SimpleFormController {

    protected final Log log = LogFactory.getLog(getClass());
    LoginDA service = new LoginDA();

    @Override
    public ModelAndView onSubmit(Object command) {

        changePassword change = (changePassword) command;
        int userID = Integer.parseInt(change.getUserID());
        service.setPassword(userID,change.getPass1());

        ModelAndView modelAndView = new ModelAndView(new RedirectView(getSuccessView()));
        modelAndView.addObject("success", "true");

        return modelAndView;

    }
}
